package cc.mrbird.febs.pay.base;

import com.baomidou.mybatisplus.core.toolkit.Assert;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;


/**
 * @ClassName PayStrategyFactory
 * @Description
 * @Author 狗蛋儿
 * @Date 2020/11/19 14:47
 * @Version V1.0
 **/
public class PayModelFactory {

    private static Map<Integer, AbstractPayStrategy> services = new ConcurrentHashMap<Integer, AbstractPayStrategy>();

    public static AbstractPayStrategy getByPayType(Integer type) {
        return services.get(type);
    }

    public static void register(Integer type, AbstractPayStrategy abstractPayChooser) {
        Assert.notNull(type, "type can't be null");
        services.put(type, abstractPayChooser);
    }

}
